<?php
namespace Modules\Activity\Http\Controllers\Admin\Jika;

use Illuminate\Http\Request;
use Illuminate\Routing\Controller;

use \Modules\Activity\Entities\Jika\SwapRecord;
// use \Modules\Activity\Entities\Jika\Task;
// use \Modules\Activity\Entities\ActivityRecord;

use Validator;
use ThrowException;
use DB;

class SwapRecordController extends Controller
{
    public function index(Request $req)
    {
        $rule = [
            'task_id' => ['required']
        ];
        Validator::make($req->all(), $rule)->fails() && ThrowException::BadRequest(); 

        $options = $req->all();

        // $options['order_by'] = ['list_weight' => 'desc'];
        // $options['with_count'] = ['records', 'skus'];
        $options['with'] = ['user', 'sku'];
        $options['where']['task_id'] = $req->task_id;

        $list = SwapRecord::getList($options);

        return $list->generateListResponse();
    }
}
